<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xml:lang="en" lang="en">
	<h:head />
	<body>
		<ui:composition template="/rootWeb.xhtml">
	    <ui:define name="header">
	        <title>挤压排产列表</title>
	        <script type="text/javascript">
				//页面载入时注册
	        	jQuery(document).ready(function(){
	        		//鼠标移入
					jQuery("#scheduleTable_data tr").live("mouseover", function() {
					  	jQuery(this).css("background-color","#CCCCCC");
					  	
					});
					//鼠标移出
					jQuery("#scheduleTable_data tr").live("mouseout", function() {
					  	jQuery(this).css("background-color","white");
					  	jQuery(this).css("color","black");
					});
				});
				
				//生成排产单时
				function onGenarateDailySchedule(xhr, status, args){
					if(args.error){
						alert(args.error);
					}else{
						pressingSchedulePreViewDlg.show();
					}
				}
				
				//生成排产单完成后
				function onGenarateDailyScheduleComplete(xhr, status, args){
					pressingSchedulePreViewDlg.hide();
					alert(args.msg) ;
				}
			</script>
			<style type="text/css">
				.datePickerInputStyle input {
				   width:80px;
				}
				.dataTableRowStyle {
					background-color: white;
					color: black ;
				}
			</style>
		</ui:define>
	    <ui:define name="body">
	    	<h:form id="form" prependId="false">
	    		<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();" />
				<p:dialog modal="true" widgetVar="statusDialog"  header="请稍候"
					draggable="false" closable="false">
					<p:graphicImage value="/resources/img/ajaxloadingbar.gif" />
				</p:dialog>
	    		<div style="white-space:nowrap;width: 100%;height:450px;overflow:auto">
	    		<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />  
				<p:dataTable id="scheduleTable" value="#{pressingScheduleTableAction.scheduleList}" var="scheduleEntry" rowKey="#{scheduleEntry}"  rowStyleClass="dataTableRowStyle"
						selection="#{pressingScheduleTableAction.selectedScheduleArray}" rowIndexVar="index" emptyMessage="没有记录！"  >
               			<f:facet name="header">
               				<p:commandButton value="加载新记录" onclick="confirmLoadNewScheduleEntriesDlg.show()" />
               				<p:spacer width="5"/>
               				<p:commandButton value="生成排产单" action="#{pressingScheduleTableAction.onGenarateDailySchedule}"  
               					oncomplete="onGenarateDailySchedule(xhr, status, args)" update=":form:pressingSchedulePreViewID"/>
               			</f:facet>
               			<p:column rendered="true" selectionMode="multiple"></p:column>
               			<p:column style="width:10px">
               				<h:outputText value="#{scheduleEntry.rowIndex}"  />
               			</p:column>
               			<p:column headerText="品名" style="width:60px">
               				<h:selectOneMenu value="#{scheduleEntry.orderDetail.mold.moldName}" disabled="true" >  
					                <f:selectItems value="#{pressingScheduleTableAction.moldNameItems}"/>
					            </h:selectOneMenu>
               			</p:column>
               			<p:column headerText="状态"  style="width:60px">
               				<h:selectOneMenu value="#{scheduleEntry.orderDetail.mold.moldState}" disabled="true">  
				                <f:selectItems value="#{pressingScheduleTableAction.moldStateItems}"/>
				            </h:selectOneMenu>
               			</p:column>
               			<p:column headerText="规格" style="width:60px">#{scheduleEntry.orderDetail.mold.moldSpecification}</p:column>
               			<p:column headerText="支数" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.orderDetail.detailQuantity}"  >
               					<f:convertNumber type="number" pattern="#,###.##"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="重量" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.orderDetail.detailWeight}"  >
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="完成数" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.finishedPressingQuantity}"  >
               					<f:convertNumber type="number" pattern="#,###.##"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="完成重量" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.finishedPressingWeight}"  >
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="剩余数" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.remainPressingQuantity}"  >
               					<f:convertNumber type="number" pattern="#,###.##"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="剩余重量" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.remainPressingWeight}"  >
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="机台" style="width:100px">
               				<p:inputText  value="#{scheduleEntry.machine.machineNumber}"  style="font-weight: bold;width:70px;"  readonly="true"/>
               				<p:commandLink value="选择" action="#{pressingScheduleTableAction.setSelectedScheduleTable(scheduleEntry)}" style="color:RED" 
               					update=":form:selectMachineDlgID" oncomplete="selectMachineDlg.show()"/>
               			</p:column>
               			<p:column headerText="班组" style="width:100px">
               				<p:inputText  value="#{scheduleEntry.team.teamName}"  style="font-weight: bold;width:70px;"  readonly="true"/>
               				<p:commandLink value="选择" action="#{pressingScheduleTableAction.setSelectedScheduleTable(scheduleEntry)}"  style="color:RED"
               					update=":form:selectTeamDlgID" oncomplete="selectTeamDlg.show()"/>
               			</p:column>
               			<p:column headerText="排产日期" style="width:50px">
               				<p:calendar value="#{scheduleEntry.scheduleDate}" size="8"  mindate="new Date();"  readonlyInput="true" styleClass="datePickerInputStyle"
    							timeZone="GMT+8" pattern="yy-MM-dd" showButtonPanel="true" navigator="true"/>
               			</p:column>
               			<p:column>
	               			<p:commandLink  value="清除" action="#{pressingScheduleTableAction.clearScheduleEntryInfo(scheduleEntry)}" update=":form:scheduleTable" style="color:RED"/>
               			</p:column>
               	</p:dataTable>
               	</div>
               	<!-- 生成挤压排产单明细预览对话框 -->
               	<p:dialog id="pressingSchedulePreViewID" header="挤压排产单明细预览" widgetVar="pressingSchedulePreViewDlg" modal="true" resizable="false" >
               		<div style="white-space:nowrap;width: 100%;height:400px;overflow:auto">
               		<p:dataTable  value="#{pressingScheduleTableAction.selectedScheduleList}" var="scheduleEntry" rowKey="#{scheduleEntry}" >
               			<p:column style="width:10px">
               				<h:outputText value="#{scheduleEntry.rowIndex}"  />
               			</p:column>
               			<p:column headerText="品名" style="width:60px">
               				<h:selectOneMenu value="#{scheduleEntry.orderDetail.mold.moldName}" disabled="true" >  
					                <f:selectItems value="#{pressingScheduleTableAction.moldNameItems}"/>
					            </h:selectOneMenu>
               			</p:column>
               			<p:column headerText="状态"  style="width:60px">
               				<h:selectOneMenu value="#{scheduleEntry.orderDetail.mold.moldState}" disabled="true">  
				                <f:selectItems value="#{pressingScheduleTableAction.moldStateItems}"/>
				            </h:selectOneMenu>
               			</p:column>
               			<p:column headerText="规格" style="width:60px">#{scheduleEntry.orderDetail.mold.moldSpecification}</p:column>
               			<p:column headerText="支数" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.orderDetail.detailQuantity}"  >
               					<f:convertNumber type="number" pattern="#,###.##"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="重量" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.orderDetail.detailWeight}"  >
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="完成数" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.finishedPressingQuantity}"  >
               					<f:convertNumber type="number" pattern="#,###.##"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="完成重量" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.finishedPressingWeight}"  >
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="剩余数" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.remainPressingQuantity}"  >
               					<f:convertNumber type="number" pattern="#,###.##"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="剩余重量" style="text-align:right;width:80px;margin:0px">
               				<h:outputText value="#{scheduleEntry.remainPressingWeight}"  >
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="机台" style="width:100px">
               				<h:outputText  value="#{scheduleEntry.machine.machineNumber}"  style="font-weight: bold;width:70px;"  />
               			</p:column>
               			<p:column headerText="班组" style="width:100px">
               				<h:outputText  value="#{scheduleEntry.team.teamName}"  style="font-weight: bold;width:70px;"  />
               			</p:column>
               			<p:column headerText="排产日期" style="width:50px">
    						<h:outputText value="#{scheduleEntry.scheduleDate}">
               						<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" />
               				</h:outputText>
               			</p:column>
               		</p:dataTable>
               		</div>
               		<f:facet name="footer">
	    				<p:commandButton value="确定"  action="#{pressingScheduleTableAction.genarateDailySchedule}" oncomplete="onGenarateDailyScheduleComplete(xhr, status, args)"
	    					/>
	    				<p:spacer width="5"/>
	    				<p:commandButton value="取消"  oncomplete="pressingSchedulePreViewDlg.hide()" />
	    			</f:facet>
               	</p:dialog>
               	<!-- 查找新订单确认框 -->
				<p:confirmDialog  message="加载新记录将要刷新表格，需要重新填写，确定加载新记录？"
					header="加载新记录" severity="alert" widgetVar="confirmLoadNewScheduleEntriesDlg">
					<p:commandButton value="加载新记录" action="#{pressingScheduleTableAction.loadNewScheduleEntries}"
						oncomplete="confirmLoadNewScheduleEntriesDlg.hide()"  update=":form:scheduleTable"/>
					<p:spacer width="5"/>
					<p:commandButton value="取消" onclick="confirmLoadNewScheduleEntriesDlg.hide()" type="button" />
				</p:confirmDialog>
				<!-- 选择机台 -->
				<p:dialog id="selectMachineDlgID" header="选择机台" widgetVar="selectMachineDlg" modal="true" resizable="false" >
               			<p:dataTable id="selectMachineTable" value="#{pressingScheduleTableAction.machineList}" var="machine" rowKey="#{machine}" emptyMessage="没有记录！"
               				selection="#{pressingScheduleTableAction.selectedMachine}"
		    				paginator="true" rows="10"  	rowsPerPageTemplate="5,10,15"	paginatorAlwaysVisible="false" 	paginatorPosition="bottom" currentPageReportTemplate="{currentPage} / {totalPages}"
	               			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   >
	               			<p:column selectionMode="single"/>
	               			<p:column headerText="机台编码">#{machine.machineCode}</p:column>
               				<p:column headerText="机台号">#{machine.machineNumber}</p:column>
               				<p:column headerText="机台状态">
	               				<h:selectOneMenu value="#{machine.machineState}" disabled="true" style="width:120px">  
					                <f:selectItems value="#{pressingScheduleTableAction.machineStateItems}"/>
					            </h:selectOneMenu>
	               			</p:column>
	               			<p:column headerText="描述">#{machine.machineRemark}</p:column>
               			</p:dataTable>
               			<f:facet name="footer">
		    				<p:commandButton value="确定" action="#{pressingScheduleTableAction.setMachineToScheduleEntry}"
		    					update=":form:scheduleTable" oncomplete="selectMachineDlg.hide()"/><p:spacer width="5"/>
		    				<p:commandButton value="取消" oncomplete="selectMachineDlg.hide()"/>
		    			</f:facet>
               	</p:dialog>
               	<!-- 选择班组 -->
				<p:dialog id="selectTeamDlgID" header="选择机台" widgetVar="selectTeamDlg" modal="true" resizable="false" >
               			<p:dataTable id="selectTeamTable" value="#{pressingScheduleTableAction.teamList}" var="team" rowKey="#{team}" emptyMessage="没有记录！"
               				selection="#{pressingScheduleTableAction.selectedTeam}"
		    				paginator="true" rows="10"  	rowsPerPageTemplate="5,10,15"	paginatorAlwaysVisible="false" 	paginatorPosition="bottom" currentPageReportTemplate="{currentPage} / {totalPages}"
	               			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   >
	               			<p:column selectionMode="single"/>
	               			<p:column headerText="班组名称">#{team.teamName}</p:column>
	               			<p:column headerText="班组编码">#{team.teamCode}</p:column>
	               			<p:column headerText="班组状态">
	               				<h:selectOneMenu value="#{team.teamState}" disabled="true">  
					                <f:selectItems value="#{pressingScheduleTableAction.teamStateItems}"/>
					            </h:selectOneMenu>
	               			</p:column>
	               			<p:column headerText="班组描述">#{team.teamRemark}</p:column>
               			</p:dataTable>
               			<f:facet name="footer">
		    				<p:commandButton value="确定" action="#{pressingScheduleTableAction.setTeamToScheduleEntry}"
		    					update=":form:scheduleTable" oncomplete="selectTeamDlg.hide()"/><p:spacer width="5"/>
		    				<p:commandButton value="取消" oncomplete="selectTeamDlg.hide()"/>
		    			</f:facet>
               	</p:dialog>
			</h:form>
	    </ui:define>
		</ui:composition>
	</body>
</html>
